import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';
import styleImport, { VantResolve } from 'vite-plugin-style-import';
// https://vitejs.dev/config/
export default defineConfig({
	base:process.env.NODE_ENV === 'production'? './webadmin': './', // 配置子目录
	// plugins: [
	// 	vue(),
	// 	styleImport({
	// 	  resolves: [VantResolve()],
	// 	  libs: [
	// 		{
	// 		  libraryName: 'vant',
	// 		  esModule: true,
	// 		  resolveStyle: name => `vant/es/${name}/style`
	// 		}
	// 	  ]
	// 	}),
	//   ],
	plugins: [
		vue(),
		Components({
		  resolvers: [VantResolver()],
		}),
	  ],
	resolve: {
		alias: {
			'@': fileURLToPath(new URL('./src', import.meta.url)),
		},
	},
	server: {
		proxy: {
			'/api': {
				target: 'http://127.0.0.1:3815',
				changeOrigin: true,
				// rewrite: path => path.replace(/^\/api/, ''),
			},
		},
	},
})
